<!DOCTYPE html>
<html>
<head lang="en">
	<meta charset="UTF-8">
	<meta name="viewport" content=" initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="format-detection" content="telephone=no">
	<title>下单确认</title>
	<script src="https://og6593g2z.qnssl.com/fundebug.0.3.3.min.js" apikey="e65b1e28cd641345cd31ef6dce8ac62f7aaa3ba3420be5a1c4aa23ee3636992d"></script>
	<link rel="stylesheet" href="{$Think.config.RESOURCEURL}wx_assets/css/common.css{$Think.config.RESOURCE_VER}" onerror="_cdnFallback(this)">
	<if condition="$mallHue.mallHue eq '1'">
		<link rel="stylesheet" href="{$Think.config.RESOURCEURL}wx_assets/css/product/product_common_order_confirm_blue.css{$Think.config.RESOURCE_VER}" onerror="_cdnFallback(this)">
		<else/>
		<link rel="stylesheet" href="{$Think.config.RESOURCEURL}wx_assets/css/product/product_common_order_confirm.css{$Think.config.RESOURCE_VER}" onerror="_cdnFallback(this)">
	</if>
	<script src="http://sdk.talkingdata.com/app/h5/v1?appid={$TDAppid}&vn=v1&vc=v1"></script>
	<script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/zepto.1.1.3.min.js{$Think.config.RESOURCE_VER}"></script>
	<script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/zepto.alert.js{$Think.config.RESOURCE_VER}"></script>
	<script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/util.js{$Think.config.RESOURCE_VER}"></script>
	<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
	<script src="{$Think.config.RESOURCEURL}wx_assets/js/wx_share.js{$Think.config.RESOURCE_VER}" type="text/javascript"></script>
	<script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/product/product.js{$Think.config.RESOURCE_VER}"></script>
	<script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/product/m_city.js{$Think.config.RESOURCE_VER}"></script>
	<script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/product/z.citys.js{$Think.config.RESOURCE_VER}"></script>
	<link href="{$Think.config.RESOURCEURL}wx_assets/iconfont/iconfont.css{$Think.config.RESOURCE_VER}" rel="stylesheet">
	<style>
		body{font-size:12px;}
		@font-face {
			font-family: 'iconfont';
			src: url('//at.alicdn.com/t/font_1465887281_1663196.eot'); /* IE9*/
			src: url('//at.alicdn.com/t/font_1465887281_1663196.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
			url('//at.alicdn.com/t/font_1465887281_1663196.woff') format('woff'), /* chrome、firefox */
			url('//at.alicdn.com/t/font_1465887281_1663196.ttf') format('truetype'), /* chrome、firefox、opera、Safari, Android, iOS 4.2+*/
			url('//at.alicdn.com/t/font_1465887281_1663196.svg#iconfont') format('svg'); /* iOS 4.1- */
		}
		.iconfont
		{
			font-size: 12px !important;
			font-family: 'iconfont' !important;
		}
		.purse{
			position: fixed;
			background-color: white;
			width: 80%;
			top: 50%;
			left: 50%;
			-webkit-transform: translate(-50%,-50%);
			border-radius: 15px;
			display:none;
			z-index:10;
		}
		.purse .title {
			position: relative;
			font-size: 18px;
			text-align: center;
			border-bottom: 1px solid #ccc;
			height: 60px;
			line-height: 60px;
		}
		.purse .title .purse-close{
			position: absolute;
			left: 10px;
			top: 0;
			color: #ccc;
			font-size: 20px !important;
		}
		.purse h1 {
			font-size: 18px;
			text-align: center;
			color: #f85395;
			padding-top: 26px;
		}
		.purse h2 {
			font-size: 12px;
			text-align: center;
			color: #aaa;
			padding-top: 10px;
			padding-bottom: 30px;
		}
		.purse .set-paypassword {
			display: block;
			margin: 0 12px;
			margin-bottom: 20px;
			background: #f85395;
			color: #fff;
			text-align: center;
			height: 50px;
			line-height: 50px;
			border-radius: 6px;
		}
		.keyboard-password {
			margin: 0 12px;
			display: flex;
			position: relative;
			background-color: #FFF;
			border: 1px solid #ccc;
			margin-bottom: 10px;
		}
		.keyboard-password li {
			flex: 1;
			position: relative;
			display: flex;
			justify-content: center;
			align-items: center;
			padding-bottom: 16.67%;
		}
		.keyboard-password li i {
			display: none;
			width: 6px;
			height: 6px;
			border-radius: 50%;
			background-color: #000;
			position: absolute;
			top: 50%;
		}
		.keyboard-password li:not(:last-child):after {
			content: '';
			width: 1px;
			height: 100%;
			position: absolute;
			right: 0;
			top: 0;
			background-color: #D9D9D9;
			transform: scaleX(0.5);
		}
		.password {
			opacity: 0;
			color: transparent;
			caret-color: transparent;
			position: absolute;
			z-index: -1;
		}
		.forgot-paypassword {
			float: right;
    	padding: 0 20px 10px 0;
			color: #368ee0;
		}
		.h5-pay-layer {
			position: fixed;
			background-color: white;
			min-width: 80%;
			top: 50%;
			left: 50%;
			transform: translate(-50%,-50%);
			border-radius: 15px;
			z-index: 10;
			text-align: center;
			display: none;
		}
		.h5-pay-layer .title{
			font-size: 16px;
			color: #494949;
			line-height: 100px;
			border-bottom: 1px solid #ccc;
		}
		.h5-pay-layer .btn-field{
			display: flex;
			line-height: 40px;
		}
		.h5-pay-layer .btn-field .btn{
			flex: 1;
			line-height: 40px;
		}
		.h5-pay-layer .btn-field .faild{
			border-right: 1px solid #ccc;
		}
		.h5-pay-layer .btn-field .success{
			color: #F75493;
		}
	</style>
</head>
<body>
<if condition="$isActivity eq '1'">
	<style>
		#addRbox{
			height:55px;
		}
		.addBack .addInfo{
			line-height:55px;
		}
	</style>
</if>
<div class="container">
	<php>if($logisticsStatue!=1){</php>
	<div class="addBack">
		<if condition="$deliverySta eq '1'">
			<if condition = "($fullName eq '') or ($phone eq '')">
				<div class="addAddress" id="selDeliveryType"><span class="addIcon">&#xe600;</span>选择收货方式</div>
				<else/>
				<div id="addRbox">
					<div class="icon">&#xe602;</div>
					<div class="addInfo">
						<php>if($isActivity!=1){</php>
						<div class="name" id="addr_fullName">收货人：{$fullName}</div>
						<div class="phone" id="addr_phone">{$phone}</div>
						<div class="address" id="addr_detail">收货地址：<span id="province">{$province}</span><span id="city">{$city}</span><span id="country">{$country}</span><span id="address">{$address}</span></div>
						<php>}else{</php>
						<div class="name" id="addr_fullName">联系人：{$fullName}</div>
						<div class="phone" id="addr_phone">手机号：{$phone}</div>
						<php>}</php>
					</div>
					<div id="selDeliveryType" class="icon" style="right: 10px;color: white;">&#xe603;</div>
				</div>
			</if>
			<else/>
			<if condition = "$storeInfo eq ''">
				<div class="addAddress" id="selDeliveryType"><span class="addIcon">&#xe600;</span>选择收货方式</div>
				<else/>
				<div id="storeInfo">
					<div class="icon">&#xe602;</div>
					<div class="addInfo">
						<div class="name" id="addr_fullName">收货人：{$fullName}</div>
						<div class="phone" id="addr_phone">{$phone}</div>
						<div class="store_name" id="store_name">自提点名称：{$storeInfo.name}</div>
						<div class="store_phone" id="store_phone">自提点电话：{$storeInfo.phone}</div>
						<div class="store_address" id="store_address">自提点地址：{$storeInfo.address}</div>
					</div>
					<div id="selDeliveryType" class="icon" style="right: 10px;color: white;">&#xe603;</div>
				</div>
			</if>
		</if>
	</div>
	<php>}</php>
	<if condition="$proSource eq '1'">
		<div class="overseas">
			<img src="{$Think.config.RESOURCEURL}wx_assets/images/product/overseas.gif{$Think.config.RESOURCE_VER}">
			<if condition="$IDName neq '' OR $IDNumber neq ''">
				<span>国外直邮的商品由于通关要求，需要提供您的身份证号和对应的真实姓名，并确保收货人姓名与身份证姓名保持一致。</span>
				<span>当前姓名：{$IDName}</span><a>去修改<i class="iconfont">&#xe611;</i></a>
				<span>身份证号：{$IDNumber}</span>
				<else/>
				<span>国外直邮的商品由于通关要求，需要提供您的身份证号和对应的真实姓名，并确保收货人姓名与身份证姓名保持一致。<a><label>去填写</label><i class="iconfont">&#xe611;</i></a></span>
			</if>

		</div>
	</if>
	<div class="main">
		<ul <php>if($logisticsStatue==1){</php>style="margin-top:0"<php>}</php>>
			<volist name="productList" id="order" key="key">
				<li>
					<div class="serialNumber" data-id="{$order.orderInfo.id}">订单编号：{$order.orderInfo.id}</div>
					<volist name="order.list" id="product">
						<div class="productInfo" onClick="onDetail('{$order.orderInfo.fromCustomerId}','{$product.pid}','{$product.sId}','{$qId}','{$miUid}','{$product.shareFromGuid}')">
							<if condition="$product['picUrl1'][1]">
								<img class="proImg" src='<php>echo $product["picUrl1"][1]["picUrl"];</php>@60w_60h_100Q' alt="{$product.name}"/>
								<else/>
								<img class="proImg" src='{$product.picUrl}@60w_60h_100Q' alt="{$product.name}"/>
							</if>
							<div class="orderInfo">
								<span class="price">
									<if condition="$type eq 'point'">
										{$product['points']}积分
										<else />￥{$product['price']}
									</if>
								</span>
								<span class="count">×{$product.reserveCount}</span>
							</div>
							<div class="proName">{$product.name}</div>
							<div style="color:#ADADAD;font-size:13px;margin-left:70px">
								<notempty name="product.sizeName">
									规格:{$product.sizeName}&nbsp;
								</notempty>
								<notempty name="product.colorName">{$product.colorName}&nbsp;</notempty>
								<volist name="product.customizedInfo" id="customized">
									<br/>{$customized.name}:{$customized.description}&nbsp;
								</volist>
							</div>
						</div>
					</volist>
					<div class="proTotal">
						<span class="proCount"> 共{$product.totalCount}件商品</span>
						<span class="priceTotle"> 商品金额合计：
							<if condition="$type eq 'point'">
								{$points}积分
								<else />￥<php>echo sprintf("%.2f",$order['orderInfo']['price']);</php>
							</if>
						</span>
					</div>
					<div class="mssage">
						<div>
							<label>留言：</label>
							<input type="text" class="remark"/>
						</div>
					</div>
					<if condition="$order.haveUserCoupon eq true">
						<div class="proTotal coupon" onclick="setCoupon('{$order.orderInfo.id}')" style="margin-top:10px" data-couponid="{$order.orderInfo.userCouponId}">
							<span class="proCount">优惠券</span>
							<notempty name="order.orderInfo.userCouponId">
								<span class="priceTotle">-￥{$order.orderInfo.money}<i class="iconfont">&#xe614;</i></span>
								<else/>
								<span class="priceTotle"><i class="iconfont">&#xe614;</i></span>
							</notempty>

						</div>
					</if>
				</li>
			</volist>
		</ul>
		<!-- 运费 -->
		<if condition="$deliverySta eq '1' AND $cost neq null AND $cost neq ''">
			<div class="proTotal cost">
				<span>运费</span>
				<if condition="$cost neq null AND $cost neq ''">
					<span style="text-align:right;float: right;">￥<php>echo sprintf("%.2f",$cost);</php></span>
					<else/>
					<span style="text-align:right;float: right;">￥0</php></span>
				</if>

			</div>
			<else/>
			<div class="proTotal cost" style="display:none">
				<span>运费</span>
				<if condition="$cost neq null AND $cost neq ''">
					<span style="text-align:right;float: right;">￥<php>echo sprintf("%.2f",$cost);</php></span>
					<else/>
					<span style="text-align:right;float: right;">￥0</php></span>
				</if>

			</div>
		</if>
		<if condition="$type eq 'point'">
			<div class="proTotal coupon" id="userPoint"  style="margin-top:10px" >
				<span class="proCount">
					<span>使用积分</span>
					<span style="color: #f75493;">（剩余积分{$pointBalance}）</span>
				</span>
				<span class="priceTotle"></span>
			</div>
		<elseif condition="$canUserBalance gt 0" />
			<div class="proTotal coupon" id="userPurse"  style="margin-top:10px" >
				<span class="proCount">使用钱包（钱包余额{$userBalance}元）</span>
				<span class="priceTotle">￥<span style="float:none" class="purseMoney">0</span><i class="iconfont">&#xe614;</i></span>
			</div>
		</if>
		<if condition="$type neq 'point'">
			<div class="payMode">
				<div>选择支付方式</div>
				<?php foreach ($payType as $k => $v) :?>
					<div class="paymodel <?php echo $v['value']; ?>">
                        <label>
                            <input type="radio" name="paymode" value="<?php echo $v['value']; ?>" <?php echo $v['value'] == $defaultPayType ? 'checked':''; ?>>
                            <img src="{$Think.config.RESOURCEURL}wx_assets/images/product/<?php echo $v['value']; ?>.jpg?v={$Think.config.RESOURCE_VER}"/>
                            <span><?php echo $v['text']; ?></span>
                        </label>
					</div>
				<?php endforeach;?>
			</div>
		</if>
	</div>
</div>
<div class="bottom">
	<if condition="$type eq 'point'">
		<span>总计：{$points}积分</span>
	<elseif condition="$lastDeliveryType eq 'delivery' and $cost neq null AND $cost neq ''" />
		<span>总计：￥<php>echo sprintf("%.2f",$price+$cost-$couponMoney);</php></span>
		<else/>
		<span>总计：￥<php>echo sprintf("%.2f",$price-$couponMoney);</php></span>
	</if>
	<if condition="$type eq 'point'">
		<a data-pay-type="{$defaultPayType}" id="submitOrderwxpay" name="submitOrder">支付{$points}积分</a>
	<elseif condition="$deliverySta eq '1'"/>
		<if condition="$canPay eq '1'">
			<a data-pay-type="{$defaultPayType}" id="submitOrderwxpay" name="submitOrder">支付￥<span id="payPrice">{$price+$cost-$couponMoney|round=2}</span></a>
			<else/>
			<a data-pay-type="{$defaultPayType}" class="disabled" name="submitOrder">支付￥<span id="payPrice">{$price+$cost-$couponMoney|round=2}</span></a>
		</if>
	<else/>
		<if condition="$canPay eq '1'">
		<a data-pay-type="{$defaultPayType}" id="submitOrderwxpay" name="submitOrder">支付￥<span id="payPrice">{$price-$couponMoney|round=2}</span></a>
		<else/>
		<a data-pay-type="{$defaultPayType}" class="disabled" name="submitOrder">支付￥<span id="payPrice">{$price-$couponMoney|round=2}</span></a>
	</if>
	</if>
</div>
<!--遮罩层-->
<div class="mask"></div>
<!--使用钱包-->
<div class="purse">
	<div class="title"><span class="purse-close iconfont" id="cancelPurse">&#xe80c;</span>请输入支付密码</div>
	<h1>使用钱包&yen;{$canUserBalance}</h1>
	<h2>（钱包余额&yen;{$userBalance}）</h2>
	<input type="number"class="password" style="opacity: 0; position: relative; left: 200vw;">
		<a class="set-paypassword" href="{$Think.config.SERVER_HOST}call.html?customerId={$customerId}&module=purse&method=setPayPassword">请先设置支付密码</a>
		<ul class="keyboard-password">
			<li><i></i></li>
			<li><i></i></li>
			<li><i></i></li>
			<li><i></i></li>
			<li><i></i></li>
			<li><i></i></li>
	  	</ul>
		<a class="forgot-paypassword" href="{$Think.config.SERVER_HOST}call.html?customerId={$customerId}&module=purse&method=contrastPhoneCode">忘记密码</a>
</div>
<!--联系人/收货地址列表-->
<div id="personal_info" class="activiy_m">
</div>
<!--新增联系人/新增联系地址-->
<div id="personal_add" class="activiy_m">
	<if condition="$isActivity eq 1">
		<h3>新增联系人<i class="lm_icon">&#xe604;</i></h3>
		<ul>
			<li>
				<span class="title">联系人: </span>
				<input type="text" placeholder="请输入姓名" id="add_name">
			</li>
			<li>
				<span class="title">联系电话:</span>
				<input type="text" placeholder="请输入电话号" id="add_phone">
			</li>
		</ul>
		<else/>
		<h3>新增收货地址<i class="lm_icon">&#xe604;</i></h3>
		<ul>
			<li>
				<span class="title">联系人: </span>
				<input type="text" placeholder="请输入姓名" id="add_name">
			</li>
			<li>
				<span class="title">联系电话:</span>
				<input type="text" placeholder="请输入电话号" id="add_phone">
			</li>
			<li id="m_city">
				<span class="title">收货地址:</span>
				<div class="cityselect-field">
					<div class="cityselect province">
						<span></span><i class="down"></i>
						<select name="province" class="p"></select>
					</div>
					<div class="cityselect city">
						<span></span><i class="down"></i>
						<select name="city" class="c"></select>						
					</div>
					<div class="cityselect area">
						<span></span><i class="down"></i>
						<select name="area" class="a"></select>
					</div>
				</div>
			</li>
			<input type="text" id="add_address" placeholder="请填写详细地址">
			<li>
				<span class="title">邮政编码:</span>
				<input type="text" placeholder="请填写邮政编码(可不填)" id="add_postcode">
			</li>
		</ul>
	</if>
	<input type="button" value="保存并使用" id="per_save">
</div>
<div id="personal_edit" class="activiy_m">

</div>
<div class="deliveryType" id="selDelivery">
	<div class="whiteBack">
		<div class="delivery_top">选择方式</div>
		<div class="delivery_main">
			<ul>
				<volist name="shipping" id="delivery">
					<if condition="$delivery.value eq 'pickup'">
						<li>
							<i class="iconfont">&#xe60c;</i>
							{$delivery.text}
							<if condition="$delivery.isDefault eq '1'">
								<div class="deliveryRadio checked" data-type="{$delivery.value}">&#xe60e;</div>
								<else/>
								<div class="deliveryRadio" data-type="{$delivery.value}">&#xe60e;</div>
							</if>
						</li>
						<elseif condition="$delivery.value eq 'delivery'"/>
						<li>
							<i class="iconfont">&#xe60d;</i>
							{$delivery.text}
							<if condition="$delivery.isDefault eq '1'">
								<div class="deliveryRadio checked" data-type="{$delivery.value}">&#xe60e;</div>
								<else/>
								<div class="deliveryRadio" data-type="{$delivery.value}">&#xe60e;</div>
							</if>

						</li>
					</if>
				</volist>
			</ul>
			<div class="line"></div>
		</div>
		<div class="delivery_bottom">
			<a id="setDelivery">确定</a>
		</div>
	</div>
</div>
<div class="h5-pay-layer">
	<div class="title">是否支付成功？</div>
	<div class="btn-field">
		<div class="btn faild">支付遇到问题</div>
		<div class="btn success">支付成功</div>
	</div>
</div>
<script type="text/javascript">
var payPasswordToken = ''
function Page() {
  this.isLoading = false;
	this.payPassword = '{$payPassword}'
};

$.extend(Page.prototype, {
		init: function () {
				this.bindEvents();
				this.initH5PayLayer();
				if (this.payPassword == 0 && !sessionStorage.getItem('payPassword')) {
					$('.keyboard-password').hide()
					$('.forgot-paypassword').hide()
				} else {
					$('.set-paypassword').hide()
				}
		},

		initH5PayLayer: function() {
			if ($.util.getParam('redirect') == 1) {
				$('.mask').show();
				$('.h5-pay-layer').show();
			}
		},

		// 绑定事件
		bindEvents: function() {
			$('.password').on('input', $.proxy(this.handlePasswordChange, this));
			$('.keyboard-password').click($.proxy(this.handlekeyboardPasswordClick, this));
			$('.h5-pay-layer .faild').click($.proxy(this.handleH5PayFaildBtnClick), this);
			$('.h5-pay-layer .success').click($.proxy(this.handleH5PaysuccBtnClick), this);
		},

		// 关闭h5支付提示框
		handleH5PayFaildBtnClick: function() {
			$('.mask').hide();
			$('.h5-pay-layer').hide();
		},

		// 用户点击支付成功后执行
		handleH5PaysuccBtnClick: function() {
			var p = {
				id: orderId,
				tplid: 1
			}
			if ('{$status}' != 'paying') {
				location.href = '{$Think.config.SERVER_HOST}call.html?customerId={$customerId}&module=product&method=orderSuccess&params=' + JSON.stringify(p);
			} else {
				$.ajax({
					type: "get",
					url: '{$Think.config.SERVER_HOST}call.json?customerId={$customerId}',
					dataType: 'json',
					data: {
						 module: 'product',
						 method: 'getOrderDetail',
						 params: JSON.stringify(p)
					},
					success: function(res) {
						if (res.status != 'paying') {
							location.href = '{$Think.config.SERVER_HOST}call.html?customerId={$customerId}&module=product&method=orderSuccess&params=' + JSON.stringify(p);
						} else {
							$('.mask').hide();
							$('.h5-pay-layer').hide();
							$.util.alert('订单未支付成功，请稍后再试！')
						}
					}
				});
			}
		},

		// 当支付密码改变时执行
		handlePasswordChange: function() {
			var value = $('.password').val();
			var length = value.length;
			$('.keyboard-password li i').each(function(index, elem) {
				if (index < length) {
					$(elem).css('display', 'block');
				} else {
					$(elem).css('display', 'none');
				}
			})
			if (length >= 6) this.handleCheckOldPwd(value);
		},

		// 调用接口验证旧密码
		handleCheckOldPwd: function(oldPwd) {
			if (this.isLoading) return
			this.isLoading = true
			$.util.pageLoading.show();
			var params = {
				oldPassword: oldPwd,
				orderId: '{$id}'
			}
			$.ajax({
					type: "post",
					url: '{$Think.config.SERVER_HOST}call.json?customerId={$customerId}',
					dataType: 'json',
					data: {
						 module: 'purse',
						 method: 'contrastPayPassword',
						 params: JSON.stringify(params)
					},
					success: $.proxy(this.handleCheckOldPwdSucc, this),
					error: $.proxy(this.handleAjaxError, this)
			});
		},

		// 验证成功后执行
		handleCheckOldPwdSucc: function(res) {
			$.util.pageLoading.hide();
			if (+res.code === 0) {
				window.payPasswordToken = res.token
				$('.password')[0].blur();
				$(".purseMoney").text('<php> echo number_format($canUserBalance,2,".","");</php>');
				if(deliverySta==1) {
						$("#payPrice").text('{$price+$cost-$couponMoney-$canUserBalance|round=2}');
				}else{
						$("#payPrice").text('{$price-$couponMoney-$canUserBalance|round=2}');
				}
				$(".mask").hide();
				$(".purse").hide();
			} else {
				$.util.alert(res.msg);
				$('.password').val('');
				$('.keyboard-password li i').css('display', 'none');
				$('.password')[0].focus();
				this.isLoading = false;
			}
		},

		// 当点击密码框时，input获取焦点
		handlekeyboardPasswordClick: function() {
			$('.password')[0].focus();
		},

		// ajax请求失败时执行
		handleAjaxError: function(err) {
			console.log(err)
		}
});

var page = new Page();
page.init();
</script>
<!-- 银行卡支付样式 -->
<style>
    .add-bank-layer {
        position: fixed;
        left: 0;
        top: 0;
        width: 100vw;
        height: 100vh;
        align-items: center;
        justify-content: center;
        display: none;
        /* display: flex; */
    }
    .add-bank-layer .bg {
        position: fixed;
        left: 0;
        top: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, .5);
    }
    .add-bank-layer .layer {
        display: flex;
        flex-direction: column;
        position: relative;
        z-index: 1000;
        width: 80vw;
        background: #fff;
        border-radius: 10px;
    }
    .add-bank-layer .layer .title{
        line-height: 40px;
        padding: 0 20px;
    }
    .add-bank-layer .layer input{
        margin: 10px 20px;
        line-height: 30px;
        border: 1px solid #ccc;
        padding-left: 6px;
    }
    .add-bank-layer .btn-field {
        display: flex;
        border-top: 1px solid #ccc;
        line-height: 40px;
        color: #3366CC;
    }
    .add-bank-layer .btn-field .cancel-btn{
        border-right: 1px solid #ccc;
    }
    .add-bank-layer .btn-field div {
        flex: 1;
        text-align: center;
    }
    .bank-card-list {
        position: fixed;
        left: 0;
        top: 0;
        width: 100vw;
        height: 100vh;
        display: none;
    }
    .bank-card-list .bg {
        position: fixed;
        left: 0;
        top: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, .5);
    }
    .bank-card-list .main {
        position: fixed;
        left: 0;
        bottom: -100%;
        width: 100vw;
        background: #fff;
    }
    .bank-card-list .main .title {
        padding: 0 20px;
        border-bottom: 1px solid #ccc;
        line-height: 40px;
    }
    .bank-card-list .main ul {
        padding: 0 20px;
    }
    .bank-card-list .main ul li{
        margin: 0;
        line-height: 40px;
        border-bottom: 1px solid #ccc;
    }
    .bank-card-list .main ul li:last-child{
        border-bottom: none;
    }
    .bank-card-list .main ul li label{
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    .bank-card-list .main ul li input {
        vertical-align: top;
        display: inline-block;
        margin: 10px 10px 10px 0;
        background-color: white;
        border: 1px solid #ccc;
        box-sizing: border-box;
        -webkit-appearance: none;
        width: 16px;
        height: 16px;
        border-radius: 50%;
    }
</style>
<!-- 添加银行卡弹框 -->
<div class="add-bank-layer">
    <div class="bg"></div>
    <div class="layer">
        <div class="title">请输入银行卡号</div>
        <input type="number" placeholder="请输入银行卡号" class="bank-number">
        <div class="btn-field">
            <div class="cancel-btn">取消</div>
            <div class="confirm-btn">确认</div>
        </div>
    </div>
</div>

<div class="bank-card-list">
    <div class="bg"></div>
    <div class="main">
        <div class="title">选择支付银行卡</div>
        <ul class="list">
            <volist name="bankList" id="vo">
                <li class="card-list">
                    <label>
                        <span class="card-number">{$vo}</span>
                        <input type="radio" name="cardNumber">
                    </label>
                </li>
            </volist>
            <li class="add-bank-btn">
                <label>
                    <span>使用新卡支付</span>
                </label>
            </li>
        </ul>
    </div>
</div>

<script>
    // 滑出银行卡列表
    $('.ainongpay').click(function() {
        $('.bank-card-list').show()
        $('.bank-card-list .main').animate({
            bottom: 0
        }, 200)
    });

    // 关闭银行卡列表
    $('.bank-card-list .bg').click(function() {
        $('.bank-card-list').hide()
        $('.bank-card-list .main').css('bottom', '-100%');
    })

    // 点击银行卡
    $('.card-list').click(function() {
        $('.bank-card-list').hide()
        $('.bank-card-list .main').css('bottom', '-100%');
        $('.ainongpay span').text($(this).find('.card-number').text());
    })
    $('.add-bank-btn').click(function() {
        $('.bank-card-list').hide()
        $('.bank-card-list .main').css('bottom', '-100%');
        $('.add-bank-layer').css('display', 'flex');
    })

    $('.add-bank-layer .cancel-btn').click(function(){
        $('.add-bank-layer').hide()
    })
    $('.add-bank-layer .confirm-btn').click(function(){
        var cardNum = $('.add-bank-layer').find('input').val()
        if (!cardNum) {
            $.util.alert('请输入银行卡号！');
            return
        }
        $('.ainongpay span').text(cardNum);
        mi.PRODUCT_ORDERPAY.submitOrder('ainongpay');
    })
</script>

<script>
	var deliverySta = '{$deliverySta}';
    var UserAgent = navigator.userAgent.toLowerCase();
    // if(UserAgent.match(/MicroMessenger/i)!="micromessenger") {
    //     $(".wxpay").hide();
    // }

    var hrefParamsArray = GetSessionIdFromHref(window.location.search);
    hrefParamsArray["userName"]='{$userName}';
    function GetSessionIdFromHref(search){
        var args = search.substring(1);
        var retval = new Array();
        args = args.split("&");
        for(var i = 0; i < args.length; i ++){
            str = args[i];
            var arg = str.split("=");
            if(arg.length <= 1) continue;

            if(arg[0] == 'params') {
                var params = decodeURIComponent(arg[1]);
                var obj = eval('(' + params + ')');
                if (obj.rootid != undefined) {
                    retval["rootid"] = obj.rootid;
                }
                if (obj.id != undefined) {
                    retval["id"] = obj.id;
                }
                if (obj.tplid != undefined) {
                    retval["tplid"] = obj.tplid;
                }
                if (obj.ptype != undefined) {
                    retval["ptype"] = obj.ptype;
                }
                if (obj.dtype != undefined) {
                    retval["dtype"] = obj.dtype;
                }
                if(obj.invoiceId != undefined){
                    retval["invoiceId"] = obj.invoiceId;
                }
            } else if(arg[0] == 'customerId') {
                retval["customerId"] = arg[1];
            }else if(arg[0] == 'userName'){
                retval["userName"] = arg[1];
            }
        }
        return retval;
    }
    var baseUrl = '{$Think.config.SERVER_HOST}';
    var hrefPath = 'call.html?customerId={$customerId}';
    var basePath = 'call.json?customerId={$customerId}';
    var rootId = hrefParamsArray["rootid"];
    var orderId = '{$id}';
    var tplid = hrefParamsArray["tplid"];
    var isfreebuy="{$freebuy}";
    var isTeamPro="{$isTeam}";
    if('{$shippingCount}'>1){
        var deliveryType = "{$lastDeliveryType}";
    }else{
        var deliveryType = "{$shipping[0]['value']}";
    }
    var browser = '{$browser}';
    var isVirtual = "{$isVirtual}";
    var teamId="{$teamId}";
    var isActivity = "{$isActivity}";
    var playOrderId = "{$playOrderId}";
    var storeId = "{$storeInfo.id}";
    var storeName = "{$storeInfo.name}";
    var proSource = '{$proSource}';
	var logisticsStatue = '{$logisticsStatue}';
</script>
<script>
    var canpay = '{$canPay}';
    if(canpay==1){
        var time = '{$payTime}'.split(":");
        var interval = setInterval(function(){
            time[1]--;
            if(time[1]<0){
                time[0]--;
                time[1]=60;
            }
            if(time[1]<=0&&time[0]<=0){
                $("#time").remove();
                $("a[name='submitOrder']").addClass("disabled").unbind("click");
            }else{
                if(time[1]<10){
                    time[1] = '0'+parseInt(time[1]);
                }
                if(time[0]<10){
                    time[0] = '0'+parseInt(time[0]);
                }
                $("#time").html(time.join(":"));
            }
        },1000);
    }
    function onDetail(formCustomerId,pId,sId,qId,miUId,shareFromGuid){
        var urlP=$.util.getParamAsObject();
        var p={
            "sId":sId,
            "id":pId,
            "miUId":miUId,
            "qId":qId,
            "fromGuid":shareFromGuid
        };
        p=encodeURIComponent(JSON.stringify(p));
        var detailUrl=baseUrl+'call.html?customerId='+formCustomerId+'&module=product&method=getProduct&params='+p;
        location.href=detailUrl;
    };
    function setCoupon(oid){
        var p={
            "oid":oid,
            "type":0,
            "ids":'{$id}'
        };
        p=encodeURIComponent(JSON.stringify(p));
        location.href=baseUrl+'call.html?customerId={$customerId}&module=product&method=couponList&params='+p;
    };
</script>
<!--选择联系人/选择收货地址-->
<script type="text/html" id="per_tpl">
	<%if(isActivity==1){%>
	<h3>请选择联系人<i class="lm_icon">&#xe604;</i></h3>
	<%if(results){%>
	<ul>
		<%for(var i=0;i<results.length;i++){
		var add = results[i];
		%>
		<%if(add.isDefault==1){%>
		<li class="current">
			<p>联系人：<span class="name"><%=add.receiverName%></span></p>
			<p>联系电话 : <span class="phone"><%=add.phone%></span></p>
			<i class="lm_icon" data-id="<%=add.id%>">&#xe605;</i>
		</li>
		<%}else{%>
		<li>
			<p>联系人：<span class="name"><%=add.receiverName%></span></p>
			<p>联系电话 : <span class="phone"><%=add.phone%></span></p>
			<i class="lm_icon" data-id="<%=add.id%>">&#xe605;</i>
		</li>
		<%}}}%>
	</ul>
	<p><span>新增联系人</span><i class="lm_icon">&#xe603;</i></p>
	<%}else{%>
	<h3>请选择收货地址<i class="lm_icon">&#xe604;</i></h3>
	<%if(results){%>
	<ul>
		<%for(var i=0;i<results.length;i++){
		var add = results[i];
		%>
		<%if(add.isDefault==1){%>
		<li class="current">
			<p><span class="name"><%=add.receiverName%></span>,<span class="phone"><%=add.phone%></span></p>
			<p>收货地址 : <span class="province"><%=add.province%></span><span class="city"><%=add.city%></span><span class="country"><%=add.country%></span><sapn class="address"><%=add.address%></sapn></p>
			<i class="lm_icon" data-id="<%=add.id%>">&#xe605;</i>
		</li>
		<%}else{%>
		<li>
			<p><span class="name"><%=add.receiverName%></span>,<span class="phone"><%=add.phone%></span></p>
			<p>收货地址 : <span class="province"><%=add.province%></span><span class="city"><%=add.city%></span><span class="country"><%=add.country%></span><sapn class="address"><%=add.address%></sapn></p>
			<i class="lm_icon" data-id="<%=add.id%>">&#xe605;</i>
		</li>
		<%}}}%>
	</ul>
	<p><span>新增地址</span><i class="lm_icon">&#xe603;</i></p>
	<%}%>
</script>
<!--编辑联系人/编辑收货地址-->
<script type="text/html" id="per_edit">
	<%if(isActivity==1){%>
	<h3>编辑联系人<i class="lm_icon">&#xe604;</i></h3>
	<ul>
		<li>
			联系人: <input type="text" value="<%=receiverName%>" id="edit_name">
		</li>
		<li>
			联系电话: <input type="text" value="<%=phone%>" id="edit_phone">
		</li>
	</ul>
	<input type="button" value="保存" id="per_saved">
	<input type="button" value="删除" id="per_del">
	<%}else{%>
	<h3>编辑收货地址<i class="lm_icon">&#xe604;</i></h3>
	<ul>
		<li>
			联系人: <input type="text" value="<%=receiverName%>" id="edit_name">
		</li>
		<li>
			联系电话: <input type="text" value="<%=phone%>" id="edit_phone">
		</li>
		<li id="m_cityed">
			收货地址: <div class="cityselect province"><span></span><i class="down"></i></div><select name="province" class="p"></select>
			<div class="cityselect city"><span></span><i class="down"></i></div><select name="city" class="c"></select>
			<div class="cityselect area"><span></span><i class="down"></i></div><select name="area" class="a"></select>
		</li>
		<input type="text" value="<%=address%>" id="edit_address" placeholder="请填写详细地址">
		<li>
			邮政编码: <input type="text" placeholder="请填写邮政编码(可不填)" value="<%=postcode%>" id="edit_postcode">
		</li>
	</ul>
	<input type="button" value="保存" id="per_saved">
	<input type="button" value="删除" id="per_del">
	<%}%>
</script>

<script>
    var m_citys = {
        isActivity: "{$isActivity}",
        url: "{$Think.config.SERVER_HOST}call.json?customerId={$customerId}",
        init:function(){
            this._initEvent();
        },
		/*关闭所有弹层*/
        _allClose:function(){
            $(".mask").fadeOut(100);
            $('#personal_info').css("bottom",($("#personal_info").height()+50)*-1);
            $('#personal_edit').css({"top":"auto","bottom":($("#personal_edit").height()+50)*-1,"position":"fixed"});
            $('#personal_add').css({"top":"auto","bottom":($("#personal_add").height()+50)*-1,"position":"fixed"});
        },
		/*点击弹层右上角关闭*/
        _close:function(){
            var me = this;
            $("#personal_info h3 i").on("click",function(){
                me._allClose();
            });
            $("#personal_add h3 i").on("click",function(){
                $('#personal_add').css("bottom",($("#personal_add").height()+50)*-1);
                $("#personal_info").show(0);
            });
            $("#personal_edit h3 i").on("click",function(){
                $('#personal_edit').css("bottom",($("#personal_edit").height()+50)*-1);
                $("#personal_info").show(0);
            });
        },
		/*初次加载联系人/收货地址列表*/
        _initEvent:function(){
            var me = this;
            var data = {
                "isActivity":"{$isActivity}"
            }
            $("#personal_info").show(0).css("bottom",($("#personal_info").height()+50)*-1);
            $("#personal_add").css("bottom",($("#personal_add").height()+50)*-1);
            $("#personal_edit").css("bottom",($("#personal_edit").height()+50)*-1);
            $.ajax({
                type: 'get',
                url: me.url,
                dataType: 'json',
                data:{
                    'module':"product",
                    "method":"getAddressList",
                    "params":JSON.stringify(data)
                },
                success: function(data){
                    if(data){
                        data.isActivity = "{$isActivity}";
                        $("#personal_info").html(template("per_tpl", data));
                    }
                    m_citys._choose();
                    m_citys._edit();
                    m_citys._new();
                    m_citys._close();
                },
                error: function(xhr, type){
//            alert('Ajax error!')
                }
            });
            $(".mask").fadeIn();
            $("#personal_info").addClass('mshow').css("bottom",0);
        },
		/*选择联系人/收货地址*/
        _choose:function(){
            var me = this;
            $("#personal_info li").unbind().on("click",function(){
                var that = $(this);
                var id = that.find("i").data("id");
                if($("#addRbox").length>0){
                    if(me.isActivity!=1){
                        $("#addr_fullName").text("收货人: " + that.find(".name").text());
                        $("#addr_phone").text(that.find(".phone").text());
						$("#province").text(that.find(".province").text());
						$("#city").text(that.find(".city").text());
						$("#country").text(that.find(".country").text());
						$("#address").text(that.find(".address").text());
                    }else{
                        $("#addr_fullName").text("联系人: " + that.find(".name").text());
                        $("#addr_phone").text("手机号："+that.find(".phone").text());
                    }
                }else{
                    var addBack = $(".addBack");
                    var html ='<div id="storeInfo">';
                    if(me.isActivity!=1){
                        html+='<div id="addRbox">\
									<div class="icon">&#xe602;</div>\
									<div class="addInfo">\
									<div class="name" id="addr_fullName">收货人：'+ that.find(".name").text()+'</div>\
									<div class="phone" id="addr_phone">'+that.find(".phone").text()+'</div>';
                        html+='<div class="address" id="addr_detail">收货地址：'
								+'<span id="province">'+that.find('.province').text()+'</span>'
								+'<span id="city">'+that.find('.city').text()+'</span>'
								+'<span id="country">'+that.find('.country').text()+'</span>'
								+'<span id="address">'+that.find('.address').text()+'</span>'+'</div>';
                    }else{
                        html+='<div id="addRbox">\
									<div class="icon">&#xe602;</div>\
									<div class="addInfo">\
									<div class="name" id="addr_fullName">联系人：'+ that.find(".name").text()+'</div>\
									<div class="phone" id="addr_phone">手机号：'+that.find(".phone").text()+'</div>';
                    }
                    html+='</div>\
									<div id="selDeliveryType" class="icon" style="right: 10px;color: white;">&#xe603;</div>\
									</div></div>';
                    addBack.html(html);
                    orderConfirm._initDelivery();
                }
                window.fullName = that.find(".name").text();
                window.phone = that.find(".phone").text();
                window.province = that.find(".province").text();
				window.city = that.find(".city").text();
				window.country = that.find(".country").text();
				window.address = that.find(".address").text();
                $.ajax({
                    type: 'get',
                    url: me.url,
                    dataType: 'json',
                    data:{
                        'module':"product",
                        "method":"setDefaultAddress",
                        "params":JSON.stringify({"id":id,"isActivity":me.isActivity})
                    },
                    success: function(){
                        me._allClose();
                    },
                    error: function(xhr, type){
//            alert('Ajax error!')
                    }
                })
                setTimeout(me._allClose,200)
            });
        },
		/*编辑联系人/收货地址*/
        _edit:function(){
            var me = this;
            $("#personal_info li i").on("click",function(event){
                event.stopPropagation();
                var id = $(this).data("id");
                $("#personal_info").hide(0);
                $.ajax({
                    type: 'get',
                    url: me.url,
                    dataType: 'json',
                    data:{
                        'module':"product",
                        "method":"editUserAddress",
                        "params":JSON.stringify({"id":id})
                    },
                    success: function(data){
                        if(data){
                            data.isActivity = "{$isActivity}";
                            $("#personal_edit").html(template("per_edit", data));
                            $("#per_saved").unbind().on("click",Savefn);
                            $("#per_del").unbind().on("click",function(){
                                $.util.ok("确定要删除吗？",function(){
                                    Delfn();
                                })
                            });
                            m_citys._close();
                            if(me.isActivity!=1){
                                $('#m_cityed').citys({province:data.province,city:data.city,area:data.country});
                            }
                        }
                    },
                    error: function(xhr, type){
//            alert('Ajax error!')
                    }
                })
                $("#personal_edit").addClass('mshow').css("bottom",0);
				/*编辑弹窗保存函数*/
                function Savefn(){
                    var nameVal = $("#edit_name").val();
                    var phoneVal = $("#edit_phone").val();
                    var provinceVal = $("#m_cityed .p").find("option:selected").text();
                    var cityVal = $("#m_cityed .c").find("option:selected").text();
                    var countryVal = $("#m_cityed .a").find("option:selected").text();
                    var addressVal = $("#edit_address").val();
                    var postcodeVal = $("#edit_postcode").val();
                    var edit_data = {
                        "id": id,
                        "isActivity":'{$isActivity}',
                        "fullname": nameVal,
                        "phone":phoneVal,
                        "province": provinceVal,
                        "city": cityVal,
                        "country": countryVal,
                        "address":addressVal,
                        "postcode": postcodeVal
                    }
                    if(nameVal =="" && phoneVal =="" && addressVal==""){
                        $.util.alert("联系人联系电话详细地址不能为空");
                    }
                    else if( nameVal==""){
                        $.util.alert("联系人不能为空");
                    }
                    else if( phoneVal ==""){
                        $.util.alert("联系电话不能为空");
                    }else if (addressVal=="") {
                        $.util.alert("详细地址不能为空");
                    }
//                    else if(!/^1\d{6,10}$/.test(phone)){
                	else if(!(/^1\d{10}$/.test(phoneVal))){
                        $.util.alert("手机号码格式错误");
                    }
                    else {
                        $.util.pageLoading.show("正在保存...");
                        $.ajax({
                            type: 'post',
                            url: me.url,
                            dataType: 'json',
                            data:{
                                'module':"product",
                                "method":"createUserAddress",
                                "params":JSON.stringify(edit_data)
                            },
                            success: function(data){
                                $.util.pageLoading.hide();
                                $.util.alert("保存成功");
                                window.fullName = nameVal
                                window.phone = phoneVal
                                window.province = provinceVal
                                window.city = cityVal
                                window.country = countryVal
                                window.address = addressVal
                                me._initEvent();
                            },
                            complete:function(){

                            },
                            error: function(xhr, type){
//            alert('Ajax error!')
                            }
                        })
                    }
                }
				/*编辑弹窗删除函数*/
                function Delfn(){
                    $.ajax({
                        type: 'post',
                        url: me.url,
                        dataType: 'json',
                        data:{
                            'module':"product",
                            "method":"deleteUserAddress",
                            "params":JSON.stringify({"id":id})
                        },
                        success: function(data){
                            $.util.pageLoading.hide();
                            $.util.alert("删除成功");
                        },
                        complete:function(){
                            me._initEvent();
                        },
                        error: function(xhr, type){
//            alert('Ajax error!')
                        }
                    })
                }
            });
        },
		/*新增联系人/收货地址*/
        _new:function(){
            var me = this;
            $("#add_name,#add_phone,#add_address").val("");
            if (me.isActivity!=1){
				/*设置三级联动默认省市区*/
                $('#m_city').citys();
            }
            $("#personal_info > p").unbind().on("click",function(){
                $("#personal_info").hide(0);
                $("#personal_add").addClass('mshow').css("bottom",0);
                $("#per_save").unbind().on("click",Newfn)
            });
            function Newfn(){
                var nameVal = $("#add_name").val();
                var phoneVal = $("#add_phone").val();
                var provinceVal = $("#m_city .p").find("option:selected").text()||"";
                var cityVal = $("#m_city .c").find("option:selected").text()||"";
                var countryVal = $("#m_city .a").find("option:selected").text()||"";
                var addressVal = $("#add_address").val();
                var postcodeVal = $("#add_postcode").val();
                var edit_data = {
                    "isActivity":'{$isActivity}',
                    "fullname": nameVal,
                    "phone":phoneVal,
                    "province": provinceVal,
                    "city": cityVal,
                    "country": countryVal,
                    "address":addressVal,
                    "postcode": postcodeVal
                }
                if(nameVal =="" && phoneVal =="" && addressVal==""){
                    $.util.alert("联系人联系电话详细地址不能为空");
                }
                else if( nameVal==""){
                    $.util.alert("联系人不能为空");
                }
                else if( phoneVal ==""){
                    $.util.alert("联系电话不能为空");
                } else if (addressVal=="") {
					$.util.alert("详细地址不能为空");
				}
//                else if(!/^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/.test(phone)){
                else if(!(/^1\d{10}$/.test(phoneVal))){
                    $.util.alert("手机号码格式错误");
                }
                else {
                    $.util.pageLoading.show("正在保存...");
                    $.ajax({
                        type: 'post',
                        url: me.url,
                        dataType: 'json',
                        data:{
                            'module':"product",
                            "method":"createUserAddress",
                            "params":JSON.stringify(edit_data)
                        },
                        success: function(data){
                            $.util.pageLoading.hide();
                            $.util.alert("保存成功");
                        },
                        complete:function(){
                            if($("#addRbox").length>0){
                                if(me.isActivity!=1){
                                    $("#addr_fullName").text("收货人: " + nameVal);
                                    $("#addr_phone").text(phoneVal);
                                    $("#addr_detail").text(provinceVal+cityVal+countryVal+addressVal);
                                }else{
                                    $("#addr_fullName").text("联系人: " + nameVal);
                                    $("#addr_phone").text("手机号"+phoneVal);
                                }
                            }else{
                                var addBack = $(".addAddress").parent();

                                var html ='';
                                if(me.isActivity!=1){
                                    html+='<div id="addRbox">\
									<div class="icon">&#xe602;</div>\
									<div class="addInfo">\
									<div class="name" id="addr_fullName">收货人：'+nameVal+'</div>\
									<div class="phone" id="addr_phone">'+phoneVal+'</div>';
                                    html+='<div class="address" id="addr_detail">收货地址：'+provinceVal+cityVal+countryVal+addressVal+'</div>';
                                }else{
                                    html+='<div id="addRbox">\
									<div class="icon">&#xe602;</div>\
									<div class="addInfo">\
									<div class="name" id="addr_fullName">联系人：'+nameVal+'</div>\
									<div class="phone" id="addr_phone">手机号：'+phoneVal+'</div>';
                                }
                                html+='</div>\
									<div id="selDeliveryType" class="icon" style="right: 10px;color: white;">&#xe603;</div>\
									</div>';
                                addBack.html(html);
                                orderConfirm._initDelivery();
                            }
                            window.fullName = nameVal
                            window.phone = phoneVal
                            window.province = provinceVal
                            window.city = cityVal
                            window.country = countryVal
                            window.address = addressVal
                            me._allClose();
                        },
                        error: function(xhr, type){
//            alert('Ajax error!')
                        }
                    })
                }
            }
        }
    }
    var orderConfirm = {
        clientHeight:$('body')[0].clientHeight,
        init:function(){
            this._initEvent();
            this._initDelivery();
        },
        _initDelivery:function(){
            $("#userPurse").click(function(){
							if ($('.purseMoney').text() <= 0) {
								$(".mask").show();
                $(".purse").show();
								$('.password')[0].focus();
							}
            });
            $("#surePurse").click(function(){
                var value = $("input[name='purse']:checked").val();
                if(value==0){
                    $(".purseMoney").text(0);
                    if(deliverySta==1){
                        $("#payPrice").text('{$price+$cost-$couponMoney|round=2}');
										}else{
                        $("#payPrice").text('{$price-$couponMoney|round=2}');
										}
                }else{
                    $(".purseMoney").text('<php> echo number_format($canUserBalance,2,".","");</php>');
                    if(deliverySta==1) {
                        $("#payPrice").text('{$price+$cost-$couponMoney-$canUserBalance|round=2}');
                    }else{
                        $("#payPrice").text('{$price-$couponMoney-$canUserBalance|round=2}');
										}
                }
                $(".mask").hide();
                $(".purse").hide();
            });
            $("#cancelPurse").click(function(){
                $(".mask").hide();
                $(".purse").hide();
            });
            $("#selDeliveryType").click(function(){
                var shippingCount = '{$shippingCount}';
                var deliveryType = '{$shipping[0]["value"]}';
                var isActivity = "{$isActivity}";
                var browser = "{$browser}";
                if(shippingCount>1){
                    $("#selDelivery").show();
                    return;
                }else if(deliveryType=='pickup'){
                    var params={
                        "oid":'{$id}'
                    };
                    var url=baseUrl+'call.html?customerId={$customerId}&module=product&method=getPickUp&params='+JSON.stringify(params);
                    location.href=url;
                }else if(deliveryType=='delivery'){
                    if(isActivity==1||browser!=1){
                        m_citys.init();
                    }else{
                        mi.PRODUCT_ORDERPAY.initAddr();
                    }
                } else {
					$.util.alert('商城物流配置错误！')
				}
            });
        },
        _initEvent:function(){
            var me = this;
            $(".paymodel").click(function(){
                $("input[name='paymode']:checked").removeAttr("checked");
                $(this).find("input[name='paymode']").attr("checked",true);
                var payType = $("input[name='paymode']:checked").val();
                var submitOrder = $("a[name='submitOrder']");
                submitOrder.data("pay-type",payType);
                submitOrder.attr("id","submitOrder"+payType);
            });
            $(".purse .purseDiv").click(function(){
                $(this).find("input").click();
            });
            $("input[name='paymode']").change(function(){
                var submitOrder = $("a[name='submitOrder']");
                submitOrder.data("pay-type",$(this).val());
                submitOrder.attr("id","submitOrder"+$(this).val());
            });
            $(window).resize(function(){
                if($('body')[0].clientHeight<me.clientHeight){
                    if($("input[type='text']:focus").length>0){
                        $("#personal_add,#personal_edit").css({"top":"0","bottom":"auto","position":"absolute"});
                    }
                }else{
                    $("#personal_add,#personal_edit").css({"top":"auto","bottom":"0","position":"fixed"});
                }
            });
            $("#setDelivery").click(function(){
                $('#selDelivery').hide();
                var type = $(".deliveryRadio.checked").data("type");
                if(!type){
                    $.util.alert("先选择收货方式！");
                    return;
                }
                window.deliveryType = type;
                if(type=="delivery"){
                    $(".cost").show();

                    deliverySta=1;
                    var value = $("input[name='purse']:checked").val();
                    if(value==1){
                        $("#payPrice").text('{$price+$cost-$couponMoney-$canUserBalance|round=2}');
					}else{
                        $("#payPrice").text('{$price+$cost-$couponMoney|round=2}');
					}
                    mi.PRODUCT_ORDERPAY.initAddr();
                }else if(type=="pickup"){
                    $(".cost").hide();
                    deliverySta=0;
                    var params={
                        "oid":'{$id}'
                    };
                    var url=baseUrl+'call.html?customerId={$customerId}&module=product&method=getPickUp&params='+JSON.stringify(params);
                    location.href=url;
                }
            });
            $("#selDelivery .delivery_main li").click(function(){
                if(!$(this).find(".deliveryRadio").hasClass("checked")){
                    $(".deliveryRadio.checked").removeClass("checked");
                    $(this).find(".deliveryRadio").addClass("checked");
                }
            });
            $(".overseas a").click(function(){
                var params={
                    "oid":'{$id}'
                };
                var url=baseUrl+'call.html?customerId={$customerId}&module=product&force=1&method=realInfo&params='+JSON.stringify(params);
                location.href=url;
            });
        }
    };
    orderConfirm.init();
</script>
<script type="text/javascript">
    var fullName = '{$fullName}';
    var phone = '{$phone}';
    var address = '{$address}';
	var province = '{$province}';
	var city = '{$city}';
	var country = '{$country}';
    var IDName = '{$IDName}';
    var IDNumber = '{$IDNumber}';
    var IDPositive = '{$IDPositive}';
    var isActivity= "{$isActivity}";
    var IDBack = '{$IDBack}';
    var sid = '{$lastBuyStoreId}';
    var type, totalPrice;
    if ('{$type}' !== 'point') {
        buyType = 'buy';
        totalPrice =  parseFloat('{$price}') * 100;
    } else {
        buyType = 'point';
        totalPrice = parseFloat('{$points}');
    }
    mi.PRODUCT_ORDERPAY.init();
</script>
<script>
    wx_share.init({
        "pkg":{
            "appId": '{$pkg.appId}',
            "timestamp": '{$pkg.timestamp}',
            "nonceStr": '{$pkg.nonceStr}',
            "signature": '{$pkg.signature}'
        },
        hide:1
    });
</script>
</body>
</html>
